"""
    基于方法创建线程
"""
import threading
import time

count = 0
lock = threading.Lock()

def run(second,name):
    global count
    lock.acquire()
    count = count + 1
    lock.release()
    print(f"执行run方法，输入参数{second=}")
    time.sleep(second*0.01)
    show = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
    print(f"{name=}执行run方法完成{show=}")


print(f'主线程{threading.current_thread().name}正在运行')
for i in range(100):
    thread = threading.Thread(target=run, args=(i,hex(i)))
    thread.start()
    thread.join()
print(f'主线程{threading.current_thread().name}运行完成')
print(count)